//
//  JPFSegmentedControl.h
//  JPFUI
//
//  Created by JPFei on 2019/3/26.
//  Copyright © 2019 JPF All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface JPFSegmentedControl : UIControl

@property(nonatomic,assign) BOOL momentary;
@property(nonatomic,readonly) NSUInteger numberOfSegments;
@property(nonatomic) NSInteger selectedSegmentIndex;
@property (nonatomic, strong, readonly, nonnull) NSArray *itemViews;
@property (nonatomic, strong, nonnull) UIFont *font;
@property (nonatomic, strong, readonly, nullable) UIView *underLine;

- (nullable instancetype)initWithItems:(nullable NSArray *)items;
- (nullable instancetype)initWithFrame:(CGRect)frame
                                titles:(nullable NSArray *)titles
                            imageNames:(nullable NSArray *)imgNames;

- (void)setTitleColor:(nullable UIColor *)color forState:(UIControlState)state;

- (void)insertSegmentWithTitle:(nullable NSString *)title
                         Image:(nullable UIImage *)image
                       atIndex:(NSUInteger)segment;

- (void)removeSegmentAtIndex:(NSUInteger)segment animated:(BOOL)animated;

#pragma mark - 设置/获取单段显示信息
- (void)setTitle:(nullable NSString *)title forSegmentAtIndex:(NSUInteger)segment forState:(UIControlState)state;      // can only have image or title, not both. must be 0..#segments - 1 (or ignored). default is nil
- (nullable NSString *)titleForSegmentAtIndex:(NSUInteger)segment forState:(UIControlState)state;

- (void)setImage:(nullable UIImage *)image forSegmentAtIndex:(NSUInteger)segment forState:(UIControlState)state;       // can only have image or title, not both. must be 0..#segments - 1 (or ignored). default is nil
- (nullable UIImage *)imageForSegmentAtIndex:(NSUInteger)segment forState:(UIControlState)state;

- (nullable UIButton *)segmentAtIndex:(NSUInteger)segment;

- (void)setEnabled:(BOOL)enabled forSegmentAtIndex:(NSUInteger)segment;


@end

NS_ASSUME_NONNULL_END
